{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "import time"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## TIME-001\n",
    "\n",
    "> 现在\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "time.time()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## TIME-003\n",
    "\n",
    "> 和其他系统交互时间数据要以什么类型合适？\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "1. 优先 time 类型\n",
    "2. 字符串\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## TIME-004\n",
    "\n",
    "> 取得时间信息(本地时间)\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "time.localtime(time.time())"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## TIME-005\n",
    "\n",
    "> 取得 utc 时间信息\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "time.gmtime(time.time())"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## TIME-006\n",
    "\n",
    "> struct_time 的年、月、日、时、分、秒、星期、本年第几日、是否夏令时\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "|   字段 | 名       |                     备注 |\n",
    "| -----: | :------- | -----------------------: |\n",
    "|     年 | tm_year  |                          |\n",
    "|     月 | tm_mon   |                          |\n",
    "|     日 | tm_mday  |             本月的第几日 |\n",
    "|     时 | tm_hour  |                          |\n",
    "|     分 | tm_min   |                          |\n",
    "|     秒 | tm_sec   |                          |\n",
    "|   星期 | tm_wday  |                          |\n",
    "| 日(年) | tm_yday  |                          |\n",
    "| 夏令时 | tm_isdst | dst:daylight saving time |\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## TIME-007\n",
    "\n",
    "> 把 struct_time 转 time\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "time.struct_time(tm_year=2008, tm_mon=8, tm_mday=8, tm_hour=8, tm_min=8, tm_sec=8, tm_wday=0, tm_yday=0, tm_isdst=0)"
      ]
     },
     "execution_count": 12,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "input = (2008, 8, 8, 8, 8, 8, 0, 0, 0)\n",
    "time.struct_time(input)"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.9.13"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
